<template>
<el-container class="hone-container">
    <!-- 头部区域 -->
    <el-header>
        <div>
            <span>保险管理系统</span>
            <em>v1.0</em>
        </div>
        <span>欢迎登录</span>
        <el-button type="info" @click="signOut">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
        <!-- 侧边栏 -->
        <el-aside :width="isCollapse? '64px':'200px'">
            <div class="toggle-button" @click="toggleCollapse">|||</div>
            <el-menu default-active="2" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" :router="true" :collapse="isCollapse" :collapse-transition="false" unique-opened>
                <el-submenu :index="item.path" v-for="(item,index) in asideDate" :key="item.index">
                    <template slot="title">
                        <i :class="item.iconName"></i>
                        <!-- 文本 -->
                        <span class="text">{{item.authName}}</span>
                    </template>
                    <!-- 二级菜单 -->
                    <el-menu-item :index="'system/'+item.path+'/'+subItem.path" v-for="subItem in item.children" v-if="!subItem.isShow">
                        <!-- @click="saveNavState('/'+subItem.path)" -->
                        <template slot="title">
                            <!-- 图标 -->
                            <i :class="subItem.icon"></i>
                            <!-- 文本 -->
                            <span>{{subItem.name}}</span>
                        </template>
                    </el-menu-item>
                </el-submenu>
            </el-menu>
        </el-aside>
        <!-- 右侧内容主体 -->
        <el-main>
            <router-view></router-view>
        </el-main>
    </el-container>
</el-container>
</template>

<script>
import {
    createNamespacedHelpers
} from "vuex";
const {
    mapState,
    mapActions
} = createNamespacedHelpers("home");

export default {
    data() {
        return {
            isCollapse: true
        }
    },
    computed: {
        ...mapState(["asideDate"]),
    },
    created() {

    },
    methods: {
        ...mapActions(['isLogin']),
        signOut() {
            localStorage.token = "";
            alert('退出')
            this.$router.push('/login')
        },
        toggleCollapse() {
            this.isCollapse = !this.isCollapse
        }
    },

};
</script>

<style lang="scss" scoped>
.hone-container {
    height: 100%;
}

.el-header {
    background-color: #373d41;
    display: flex;
    justify-content: space-between;
    padding-left: 0;
    align-items: center;
    color: #fff;
    font-size: 20px;

    >div {
        display: flex;
        align-items: center;

        img {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            border: 2px solid gray;
            background-color: #fff;
            box-sizing: border-box;
            padding-top: 8px;
        }

        span {
            margin-left: 20px;
        }

        em {
            color: gray;
            font-size: 14px;
            margin-top: 7px;
            margin-left: 8px;
        }
    }
}

.el-aside {
    background-color: #333744;

    .el-menu {
        border: 0;
    }
}

.el-main {
    background-color: #eaedf1;
}

.toggle-button {
    background-color: #4a5064;
    font-size: 10px;
    line-height: 24px;
    color: #fff;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
}
</style>
